Skip to content

feat(observe): allow disabling function io capture by env var#1196

Merged
hassiebp merged 2 commits intomainfrom
add-env-var-observe-io-capture
May 27, 2025
Merged

feat(observe): allow disabling function io capture by env var#1196
hassiebp merged 2 commits intomainfrom
add-env-var-observe-io-capture

Conversation

@hassiebp
Copy link
Copy Markdown
Contributor

@hassiebp hassiebp commented May 27, 2025

Important

Add environment variable to control IO capture in @observe decorator, improving performance for large objects.

  • Environment Variables:
    • Add LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED to environment_variables.py to control IO capture in @observe decorator.
    • Default value is True, allowing automatic capture of function args, kwargs, and return values.
  • Decorator Behavior:
    • Modify LangfuseDecorator.observe() in observe.py to check LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED.
    • IO capture (capture_input and capture_output) is conditional on the environment variable being True.
  • Performance:
    • Disabling IO capture can improve performance for functions with large or deeply nested objects.

This description was created by Ellipsis for a9cc9f1. You can customize this summary. It will automatically update as commits are pushed.

Greptile Summary

Disclaimer: Experimental PR review

Added environment variable LANGFUSE_OBSERVE_DECORATOR_IO_CAPTURE_ENABLED to control automatic function input/output capture in the @observe decorator, helping optimize performance when dealing with large objects.

  • Added new environment variable definition in langfuse/_client/environment_variables.py with clear documentation about performance implications
  • Modified langfuse/_client/observe.py to respect the environment variable setting when determining if IO capture should be enabled
  • Environment variable defaults to True and combines with per-function capture flags using logical AND
  • Implementation maintains type safety and consistency across both synchronous and asynchronous code paths

@hassiebp hassiebp enabled auto-merge (squash) May 27, 2025 08:04
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hassiebp hassiebp disabled auto-merge May 27, 2025 08:14
@hassiebp hassiebp merged commit 3dd812a into main May 27, 2025
7 of 8 checks passed
@hassiebp hassiebp deleted the add-env-var-observe-io-capture branch May 27, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant